/**
 * Progetto PRAISED.
 * 24/gen/2011
 */
package it.uniroma3.engine.model;


/**
 * CandidateProteinName : This class represents a name of the dictionary that is consider to be a protein name
 * 
 * @author Accosta Augusto
 * @author Lopez Elisabetta
 *
 */
public class CandidateProteinName implements Comparable<CandidateProteinName> {

	private String candidateProtein; // The protein name associated to the candidate
	private float rank; // The rank associated to the candidate
	
	/**
	 * Constructor
	 */
	public CandidateProteinName(String candidateProtein, float rank) {
		this.candidateProtein = candidateProtein;
		this.rank = rank;
	}

	/**
	 * @param candidateProtein the candidateProtein to set
	 */
	public void setCandidateProtein(String candidateProtein) {
		this.candidateProtein = candidateProtein;
	}

	/**
	 * @return the candidateProtein
	 */
	public String getCandidateProtein() {
		return this.candidateProtein;
	}

	/**
	 * @param rank the rank to set
	 */
	public void setRank(float rank) {
		this.rank = rank;
	}

	/**
	 * @return the rank
	 */
	public float getRank() {
		return this.rank;
	}
	
	/**
	 * This method return the string value for a CandidateProteinName object
	 */
	public String toString() {
		return this.candidateProtein + "\t" + this.rank;
	}
	
	/**
	 * This method tell us if the two candidates are equals.
	 * For us the two candidates are equals when they have the same names
	 * 
	 * @param cpn
	 * @return true if the candidates are equals following the above assumption
	 */
	@Override
	public boolean equals(Object obj) {
		return this.candidateProtein.equals(((CandidateProteinName)obj).candidateProtein);
	}

	@Override
	public int hashCode() {
		return this.candidateProtein.hashCode();
	}

	@Override
	public int compareTo(CandidateProteinName cpn) {
		if(this.getRank() < cpn.getRank())
			return 1;

		if(this.getRank() > cpn.getRank())
			return -1;
		
		return 0;
	}

}
